package uk.co.hs.service.admin.interfaces;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentMap;

import org.joda.time.DateTime;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException;

import uk.co.hs.domain.web.WebRole;
import uk.co.hs.domain.web.WebUser;
import uk.co.hs.web.util.AdminListDTO;

public interface WebUserServiceInterface extends AdminServiceInterface
{
  public void changePassword(String aUserName, String aNewUnencodedPassword) throws DataIntegrityViolationException, HibernateOptimisticLockingFailureException, DataAccessException, Exception;

  public void delete(WebUser aUser) throws DataIntegrityViolationException, HibernateOptimisticLockingFailureException, DataAccessException, Exception;

  public String encodePassword(String aPassword);

  public String generateRandomPasswordString();

  public List<WebUser> getAll();

  public Map<String, Boolean> getAllowedUrls(String aUsername);

  /**
   * @see uk.co.hs.service.admin.interfaces.AdminServiceInterface
   * #getAllSortedRecords()
   * {@inheritDoc}
   */
  public List<AdminListDTO> getAllSortedRecords();

  public ConcurrentMap<String, String> getAllUserRoles();

  public ConcurrentMap<String, ConcurrentMap<String, Boolean>> getAllUsersAllowedUrls();

  public boolean getCredentialsExpired(Boolean aNewPasswordExpired, DateTime aLastPasswordChangeDate);

  public WebRole getRole(Long aPk);

  public WebUser getWebUser(Long aId);

  public WebUser getWebUser(String aUsername);

  public WebUser getWebUserIncludingPasswordHistory(String aUserName);

  public String incrementFailedLoginAttempts(String aUsername);

  public void lockUser(String aUsername);

  public boolean passwordsMatch(String aUserName, String aPasswordEntered);

  public void resetFailedLoginAttempts(String aUsername);

  public String[] resetPassword(String aUserName) throws DataIntegrityViolationException, HibernateOptimisticLockingFailureException, DataAccessException, Exception;

  public void save(WebUser aUser) throws DataIntegrityViolationException, HibernateOptimisticLockingFailureException, DataAccessException, Exception;

  public String saveUserAndLinkRoleAndLinkFowarding(WebUser aUser, Long aRolePk, Long aForwardingPk, boolean aIsNew) throws DataIntegrityViolationException, HibernateOptimisticLockingFailureException, DataAccessException, Exception;
}
